var live = '泊头';
function loadXMLDoc()
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		// IE6, IE5 浏览器执行代码
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var json = JSON.parse(xmlhttp.responseText);
			console.log(json);
			var wli = document.querySelectorAll('#weather li');
			console.log(wli);
			for(var i = 0; i < wli.length; i++){
				//天气
				wli[i].children[1].innerHTML = json.daily_forecast[i].cond.txt_n;
				//摄氏度
				wli[i].children[2].children[0].innerHTML = json.daily_forecast[i].tmp.max;
				wli[i].children[2].children[1].innerHTML = json.daily_forecast[i].tmp.min;
				//风
				wli[i].children[3].innerHTML = json.daily_forecast[i].wind.sc + '级';
			}
			var rli = document.querySelectorAll('#report li');
			for(var j = 0; j < rli.length; j++){
				rli[j].children[0].innerHTML = json.hourly_forecast[j].date;
				
			}
		}
	}
	xmlhttp.open("GET","https://bird.ioliu.cn/weather?city=" + live,true);
	xmlhttp.send();
}

loadXMLDoc();


document.querySelector('#inp').addEventListener('change',function(){
	console.log(this.value);
	live = this.value;
	loadXMLDoc();
})